<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
$(document).ready(function(){
	$(".cls").datepicker({
		dateFormat:"yy-mm-dd",changeYear:true,changeMonth:true,maxDate:"0y 0m",minDate:"-60y",
		monthNamesShort:["1월", "2월", "3월", "4월", "5월", "6월","7월", "8월", "9월", "10월", "11월", "12월"],
		showButtonPanel:true,closeText:"닫기",
		dayNamesMin:[ "일", "월", "화", "수", "목", "금", "토" ]});
});
</script>
<script type="text/javascript">
function checkAll(){  
	var chk = document.getElementsByName("stateorder"); //checkbox 배열  
	     for (var i = 0; i < chk.length; i++){
	         chk[i].checked = document.getElementById("allchk").checked;
	     }//체크박스 배열을 돌려서체크박스배열 체크상태와 윈도.도큐먼트.form1.경로의 name을 allchk로 지은 
	     //라벨의 체크상태를 같이 만든다.
}
function getManagement(){

	if($("#enumerate").val()=='전체'){
		alert("검색구분을 선택해주세요.");
		$("#enumerate").focus();
		return false;
	}
	if($("#search").val()==''){
		alert("검색어를 입력 해주세요.");
		$("#search").focus();
		return false;
	}
	
	if($("#period").val()==''){
		alert("검색조건 설정해주세요.");
		$("#period").focus();
		return false;
	}
	if($("#startDate").val()==''){
		alert("기간을 설정해주세요.");
		$("#startDate").focus();
		return false;
	}
	if($("#endDate").val()==''){
		alert("기간을 설정해주세요.");
		$("#endDate").focus();
		return false;
	}
	if(document.getElementsByName("stateorder").value==''){
		alert("주문상태를 체크해주세요.");
		$("#stateorder").focus();
		return false;
	}
	
}
</script>

</head>
<body>
<style type="text/css">
 	
  	.headline {margin-top: 0px; margin-bottom: 10px; margin-right: auto;}
  	.headtext {font-weight: bolder; color:#B061BF; margin-top: 20px; margin-bottom: 0px; font-style: 돋음; }
</style>
<h2 class="headtext">환불 관리</h2>
<hr class="headline">
	<form id="refundManagementForm" action="/${initParam.context_root }/order/getRefundManagement.do" onsubmit="return getManagement()">
		<table>
			<tr>
				<td><b>검색어</b></td>
				<td><select id="enumerate" name="enumerate">
						<option>전체</option>
						<option value="order_number">주문번호</option>
						<option value="orderer">주문자</option>
						<option value="product_name">상품명</option>
						<option value="cust_id">회원번호</option>
				<td><input type="text" onfocus="" size="100" name="search" id="search" placeholder="검색어를 입력하세요" style="width: 400px;">
				</td>
			</tr>
			<tr>
				<td><b>기간</b></td>
				<td><select id="period" name="period"><option value="order_date">주문일</option><option value="refund_date">환불신청일</option></select></td>
				<td>시작 <input type="text" name="startDate" id="startDate" class="cls">~ 종료 <input type="text" name="endDate" id="endDate" class="cls"></td>
			</tr> 
			<tr>
				<td colspan="3">
					주문상태
					전체<input type="checkbox" name="stateorder" id="allchk" onclick="checkAll()"> 
					교환신청<input type="checkbox" name="stateorder" value="n">  
					교환완료<input type="checkbox" name="stateorder" value="y">
				</td>
			</tr>
			<tr>
				<td colspan="3" align="center">
					<input type="submit" value="검색">
					<input type="reset" value="초기화" id="reset">
				</td>
			</tr>
		</table>
	</form>



<h3 class="headtext">검색 결과</h3>
<hr class="headline">
<table class="table table-bordered"  align="center" width="500" border='1' cellspacing="0">
		<thead>
			<tr align="center" style="background-color:#453949; color: white;">
				<td>환불신청일(환불접수일)</td>
				<td>주문번호</td>
				<td>주문자</td>
				<td>상품명</td>			
				<td>환불 처리</td>
				<td>환불액</td>
				<td>환불 방법</td>
			</tr>
		</thead>

		<tbody>
			<c:forEach items="${requestScope.refundManagement_list}" var="refundManagement">
				<tr>
					<td>${refundManagement.refundDate}</td>
					<td>${refundManagement.orderNumber}</td>
					<td>${refundManagement.orderer}</td>
					<td>${refundManagement.productName}</td>
					<td>${refundManagement.refundProcess}</td>
					<td>${refundManagement.refundMoney}</td>
					<td>${refundManagement.refundWay}</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>


<p><!-- 페이징 처리 member/memberListPaging.do?page=값-->
<!-- 이전페이지 그룹으로 이동 -->
	<!-- 이전페이지 그룹이 있으면 링크, 없으면 걸지 않는다. -->
	<c:choose>
	<c:when test="${requestScope.paging.previousPageGroup }">
		<a href="/${initParam.context_root }/order/getManagement.do?page=${requestScope.paging.startPageOfPageGroup-1}&sort=${requestScope.enumerate }&startDate=${requestScope.startDate }&endDate=${requestScope.endDate }">☜</a>
	</c:when>
	<c:otherwise>
	☜
	</c:otherwise>
	</c:choose>
<!-- 페이지 번호들 출력 -->
	<!-- 
	현재페이지가 속한 그룹의 시작 페이지부터 마지막 페이지까지 1씩 증가한 값들을 출력
	- 링크 처리(단 현재페이지는 링크 처리 안함)
	 -->
<c:forEach begin="${requestScope.paging.startPageOfPageGroup }" end="${requestScope.paging.endPageOfPageGroup }" var="page">
	<c:choose>
		<c:when test="${page==requestScope.currentPage }">
			[${page }]
		</c:when>
		<c:otherwise>
			<a href="/${initParam.context_root }/order/getManagement.do?page=${page }&sort=${requestScope.sort }&startDate=${requestScope.startDate }&endDate=${requestScope.endDate }">${page }</a>
		</c:otherwise>
	</c:choose>
</c:forEach>
<!-- 다음 페이지 그룹으로 이동 -->
	<!--  -->
	<c:choose>
	<c:when test="${requestScope.paging.nextPageGroup }">
		<a href="/${initParam.context_root }/order/getManagement.do?page=${requestScope.paging.endPageOfPageGroup+1}&sort=${requestScope.sort }&startDate=${requestScope.startDate }&endDate=${requestScope.endDate }">☞</a>
		</c:when>
	<c:otherwise>
	☞
	</c:otherwise>
	</c:choose>
<div>
		<a href="/${initParam.context_root }/order/managementView.do">엑셀다운로드</a>
</div>
</body>
</html>